package sanmubird.scratch.y210914;

import com.google.common.collect.Lists;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import static sanmubird.scratch.y210914.TypeEnum.*;

/**
 * @author sam
 * @date 2021/9/17 21:26
 */
public class Main {


    public static List<Person> prepareApprovalPersonList() {
        return Lists.newArrayList(
                Person.builder()
                        .personId(1L)
                        .preferenceList(
                                Lists.newArrayList(
                                        Person.Preference.builder().type(PIC).priority(7).build()
                                        , Person.Preference.builder().type(VIDEO).priority(3).build()
                                )
                        )
                        .todoList(Lists.newArrayList())
                        .build(),

                Person.builder()
                        .personId(2L)
                        .preferenceList(
                                Lists.newArrayList(
                                        Person.Preference.builder().type(AUDIO).priority(7).build()
                                        , Person.Preference.builder().type(VIDEO).priority(3).build()
                                )
                        )
                        .todoList(Lists.newArrayList())
                        .build(),

                Person.builder()
                        .personId(3L)
                        .preferenceList(
                                Lists.newArrayList(
                                        Person.Preference.builder().type(AUDIO).priority(5).build()
                                        , Person.Preference.builder().type(VIDEO).priority(3).build()
                                        , Person.Preference.builder().type(PIC).priority(2).build()
                                )
                        )
                        .todoList(Lists.newArrayList())
                        .build(),

                Person.builder()
                        .personId(4L)
                        .preferenceList(
                                Lists.newArrayList(
                                )
                        )
                        .todoList(Lists.newArrayList())
                        .build()
        );
    }


    public static List<Task> prepareTaskList() {
        return IntStream.range(0, 10)
                .mapToObj(
                        n -> Task.builder()
                                .taskId((long) n)
                                .tagList(
                                        Lists.newArrayList(
                                                Task.Tag.builder().type(PIC).order(n).build()
                                                , Task.Tag.builder().type(VIDEO).order(10 - n).build()
                                                , Task.Tag.builder().type(AUDIO).order(2 * n).build()
                                        )
                                )
                                .build()
                )
                .collect(Collectors.toList());
    }


    public static void main(String[] args) {

        List<Task> tasks = prepareTaskList();
        List<Person> personList = prepareApprovalPersonList();

        Dispatch dispatch = new Dispatch(tasks, personList);
        dispatch.main();


    }
}
